package com.kusiri.kframework.salesforce.model.valueobjectlist
{
	import com.kusiri.kframework.model.KfValueObjectList;
	import com.kusiri.kframework.model.KfValueObjectsChangedEvent;
	import com.kusiri.kframework.salesforce.model.IKfSalesforceModel;

	public class SObjectList extends KfValueObjectList implements ISObjectList
	{
		protected var _model : IKfSalesforceModel;
		
		/**
		 * To be set programatically
		 */
		public var _type : String;
		
		
		public function SObjectList()
		{
			super();
		}
		
		/**
		 * Returns the sobject type
		 */
		public function get type() : String
		{
			return _type;
		}
		
		
		public function get model() : IKfSalesforceModel
		{
			return _model;
		}
		
		public function set model( model : IKfSalesforceModel ) : void
		{
			_model = model;
		}
		
		/**
		 * Tell the Component to get ready to be used.
		 * 
		 * Called from the KfComponentManager, not called directly.
		 * 
		 * Callback functions take component, and the error (if applicable) as the argument
		 */
		override public function __initializeComponent(onSuccess : Function, onFail : Function) : void
		{
			// hook up to listen for data changed events
			model.addEventListener(KfValueObjectsChangedEvent.EVENT_NAME, onDataChange, false, 0, true);

			super.__initializeComponent(onSuccess, onFail);
		}
		
	}
}